class LinkNode{
    constructor(val){
         this.val=val;
         this.next=null
    }
    append(val){
        let cur=this;
        while(cur.next!==null){
            cur=cur.next
        }
        cur.next=val
    }
}
const l1=new LinkNode(1)
const l2=new LinkNode(2)
l1.next=l2
const l3=new LinkNode(3)
l1.append(l3)

/**
 * 
 * @param {l1} LinkNode 
 * @param {l2} LinkNode
 */
function mergeTowLinkNode(l1,l2){
    const head=new LinkNode()
    const cur=head;
    while( l1 && l2 ){     
        if(l1.val>=l2.val){
            cur.next=l1;
            l1 = l1.next
        // .next = l1.next
            // l1.next=l1.next.next
        }else{
            cur.next=l2;
            l2=l2.next
        }
        cur = cur.next
    }
    cur.next=l1!==null?l1:l2
    return head.next
}

/**
 * 
 * @param {head} LinkNode 
 */

function deleteDuplicates (head){
    let cur=head
    while(cur!=null&&cur.next!=null){
        if(cur.val===cur.next.val){
            cur.next=cur.next.next
        }else{
            cur=cur.next
        }
        
    }
    return head
}
/**
 * 删除所有含有重复数字的结点  
 * 
 */

function deleteDuplicates2(head){
    if(!head||!head.next){
        return head
    }
    const dummy=new LinkNode()
    dummy.next=head;
    let cur=dummy;
    while(cur.next&&cur.next.next){
        if(cur.next.value===cur.next.next.value){
            let value = cur.next.value
            while(cur.next&&cur.next.value===value){
                cur.next=cur.next.next
            }
        }else{
            cur=cur.next
        }
    }
    return dummy.next
}
